package javaMultiThreadInAction.chapter01;

/**
 * @author xinya
 * @version 1.0
 * @project javacore
 * @description 1-6 简易的倒计时器
 * @date 2024/1/9 10:37:36
 */
public class SimpleTimer {
    private static int count;

    public static void main(String[] args) {
        count = args.length >= 1 ? Integer.valueOf(args[0]) : 60;
        int remaining;

        while (true) {
            remaining = countDown();

            if(0 == remaining) {
                break;
            } else {
                System.out.println("remaining " + count + " seconds(s)");
            }

            try {
                Thread.sleep(2000);
            } catch (InterruptedException e) {

            }

        }
        System.out.println("done");
    }

    private static int countDown() {
    return count --;
    }
}
